package com.sys.common.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.Serial;
import java.io.Serializable;

/**
 * 读取项目相关配置
 *
 * @author LGY
 */
@Data
@Component
@ConfigurationProperties(prefix = "sys")
public class SysConfigProperties implements Serializable {

    @Serial
    private static final long serialVersionUID = 1283253610363750393L;
    /**
     * 上传路径
     */
    public static String profile;

    /**
     * 获取地址开关
     */
    public static boolean addressEnabled;

    /**
     * 验证码类型
     */
    public static String captchaType;

    public void setProfile(String profile) {
        SysConfigProperties.profile = profile;
    }

    public void setAddressEnabled(boolean addressEnabled) {
        SysConfigProperties.addressEnabled = addressEnabled;
    }

    public void setCaptchaType(String captchaType) {
        SysConfigProperties.captchaType = captchaType;
    }

    /**
     * 获取导入上传路径
     */
    public static String getImportPath() {
        return SysConfigProperties.profile + "/import";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath() {
        return SysConfigProperties.profile + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath() {
        return SysConfigProperties.profile + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath() {
        return SysConfigProperties.profile + "/upload";
    }
}
